package io;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;

public class Test2 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("note.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入：");
        while (true){
            String line = scan.nextLine();
            if ("exit".equalsIgnoreCase(line)){
                break;
            }
            osw.write(line);
        }
        System.out.println("写入完毕");
        osw.close();
    }


}
